using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using MathematicallySafe.HeadCounter.Data;
using MathematicallySafe.HeadCounter.Data.Interfaces;
using StructureMap;

namespace MathematicallySafe.HeadCounter.Converters
{
    public class OutlierColourConverter : IValueConverter
    {
        private static readonly IGuild Guild = ObjectFactory.GetInstance<IGuild>();

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var v = (double) value;

            if (v <= Guild.WeightedLootRateLow)
            {
                return Application.Current.Resources["BelowRateThresholdColour"];
            }

            if (v >= Guild.WeightedLootRateHigh)
            {
                return Application.Current.Resources["AboveRateThresholdColour"];
            }

            return "Transparent";
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }

        #endregion
    }
}